<?php

namespace common\models\shop;

use Yii;
use yii\db\ActiveRecord;

/**
 * Desc 店铺
 */
class Store extends ActiveRecord {

    //总店
    const TYPE_MAIN_STORE = 1;
    //分店
    const TYPE_BRANCH_STORE = 2;
    
    //职位-商户(老板)
    const POSITION_BOSS = 1;
    //职位-店长
    const POSITION_MANAGER = 2;
    //职位-店员
    const POSITION_CLERK = 3;
    
    //状态-启用
    const STATUS_ENABLE = 1;
    //状态-禁用
    const STATUS_DISABLE = 2;

    public static $position = [
        self::POSITION_MANAGER => '店长',
        self::POSITION_CLERK => '店员',
    ];
    
    public static $type = [
        self::TYPE_MAIN_STORE => '总店',
        self::TYPE_BRANCH_STORE => '分店',
    ];
    public static $status = [
        self::STATUS_ENABLE => '启用',
        self::STATUS_DISABLE => '禁用',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%pay_store}}';
    }
    
    /**
     * Desc 获取店铺一条记录
     * @param array $where ['id'=>value]/['AND',['=','id',value],['like','']]
     * @return array
     */
    public static function getOne($where,$field = []){
        return self::find()->select(empty($field)?$field:['mer_id','name','position','contacts','phoen','password','address','status'])->asArray()->where($where)->one();
    }

}
